package com.hdoit.kylin.web.user.modelconfig;

import com.hdoit.kylin.web.user.provider.TeacherRoleProvider;
import com.tennetcn.common.enums.ManageContainer;
import com.tennetcn.common.enums.regular.RegularExpressions;
import com.tennetcn.component.attribute.DisplayNameAttribute;
import com.tennetcn.component.attribute.DropDownListAttribute;
import com.tennetcn.component.attribute.RegularExpressionAttribute;
import com.tennetcn.component.attribute.RemoteAttribute;
import com.tennetcn.component.attribute.RequiredAttribute;
import com.tennetcn.component.attribute.base.ModelMetadataAttributeConfiguration;
import com.tennetcn.web.cbase.providers.SexProvider;
import com.tennetcn.web.superbase.providers.RoleProvider;

public class TeacherConfig extends ModelMetadataAttributeConfiguration{
	public TeacherConfig(){
		this.setProperty("teacherName")
			.hasAttribute(new DisplayNameAttribute("姓名"))
			.hasAttribute(new RequiredAttribute("姓名为必填项"));
		
		RemoteAttribute RemoteAttribute=new RemoteAttribute();
		RemoteAttribute.setAdditionalfields("*.employeeId,*.employeeAccount");
		RemoteAttribute.setErrorMessage("已经存在相应的帐号");
		RemoteAttribute.setRemoteUrl(ManageContainer.VIRTUALPATH+"/admin/user/teacher/checkAccount");
		this.setProperty("employeeAccount")
			.hasAttribute(new DisplayNameAttribute("帐号"))
			.hasAttribute(new RequiredAttribute("帐号为必填项"))
			.hasAttribute(RemoteAttribute);

		this.setProperty("sex")
			.hasAttribute(new DisplayNameAttribute("性别"))
			.hasAttribute(new DropDownListAttribute(new SexProvider()));
		this.setProperty("mobile")
			.hasAttribute(new DisplayNameAttribute("电话"))
			.hasAttribute(new RegularExpressionAttribute(RegularExpressions.mobile));
		this.setProperty("email")
			.hasAttribute(new DisplayNameAttribute("邮箱"))
			.hasAttribute(new RegularExpressionAttribute(RegularExpressions.email));
		this.setProperty("comments")
			.hasAttribute(new DisplayNameAttribute("备注"));
		this.setProperty("teacherId")
			.hasAttribute(new DisplayNameAttribute("工号"));
		this.setProperty("roleIds")
			.hasAttribute(new DisplayNameAttribute("职称"))
			.hasAttribute(new RequiredAttribute())
			.hasAttribute(new DropDownListAttribute(new TeacherRoleProvider(),false));
			
	}
}
